<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    
    <h:head>
        <title>#{names.title}</title>
    </h:head>
    
    <h:body rendered="#{!auth.loggedIn}">
        <ui:include src="login.xhtml" />
    </h:body>
    
    <h:body rendered="#{auth.loggedIn}">
        <h:outputStylesheet library="css" name="style.css"  />
        <h:panelGroup layout="block" class="wrapper">
            <p:panel id="admin_panel" header="#{names.title}" style="margin-bottom:10px;">       
                <ui:include src="header.xhtml" /> 
                <p:panel id="new_room_panel" header="#{names.roomCreatePanelName}" style="margin-bottom:10px;" styleClass="small">
                    <h:form id="new_room">
                       <h:panelGrid columns="3">
                           <p:outputLabel for="building" value="#{names.roomAttributeBuilding}" />
                           <p:inputText id="building" value="#{room.building}" required="true" requiredMessage="#{names.roomAttributeBuildingMsg}"/>
                           <p:message for="building" />
                           <p:outputLabel for="roomName" value="#{names.roomAttributeRoom}" />
                           <p:inputText id="roomName" value="#{room.name}" required="true" requiredMessage="#{names.roomAttributeRoomMsg}"/>
                           <p:message for="roomName" />                          
                           <p:outputLabel  value="" />
                           <p:commandButton id="submit" icon="ui-icon-plus" value="#{names.buttonCreate}" ajax="false" actionListener="#{rooms.add(room)}"/>
                       </h:panelGrid>
                   </h:form>                        
                </p:panel>
                <p:panel id="all_rooms_panel" header="#{names.allRoomsPanelName}" style="margin-bottom:10px;" styleClass="small">
                    <h:form id="edit_room">
                        <p:dataTable id="table_rooms" var="r" value="#{rooms.rooms}"
                                     sortMode="multiple" paginator="true" rows="15" paginatorTemplate="{PageLinks}"
                                     emptyMessage="#{names.noEntries}">
                            <p:ajax event="rowDblselect" listener="#{personPickList.updateRoom}" />
                            <p:column sortBy="#{r.building}" headerText="#{names.roomAttributeBuilding}">
                                <h:outputText value="#{r.building}" />  
                            </p:column>                      
                            <p:column sortBy="#{r.name}" headerText="#{names.roomAttributeRoom}">
                                <h:outputText value="#{r.name}" />  
                            </p:column>    
                            <p:column style="width:100px;"> 
                                <p:commandButton id="viewButton" icon="ui-icon-pencil" value="#{names.buttonEdit}" action="#{rooms.gotoEdit}">
                                    <f:param name="edit" value="#{r.id}"/>
                                </p:commandButton>
                            </p:column>
                        </p:dataTable>
                    </h:form>
                </p:panel>
            </p:panel>
        </h:panelGroup>
    </h:body>
</html>
